﻿
@{
    //ViewBag.Title = "Index";
    // Layout = "~/Views/Shared/_Layout.cshtml";
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>诊间支付后台系统登录</title>
    @Styles.Render("~/Content/css")
    <style>
        body {
            height: 100vh;
            width: 100%;
            overflow-y: hidden;
            overflow-x: hidden;
            font-size:18px;
            margin:0;
            padding:0;
        }

        .body-content {
            background-color: rgba(232, 232, 230, 0.905882352941176);
            height: 100vh;
            width: 100%;
            overflow-y: hidden;
        }

        .login-contanier {
            background-color: white;
            width: 560px;
            height: 290px;
            border-radius: 15px;
            margin-top: 12%;
            margin-left: 35%
        }

        .title-name {
            text-align: center;
            font-family: 'Arial Negreta', 'Arial Normal', 'Arial';
            font-weight: 700;
            font-style: normal;
            font-size: 30px;
            height: 40px;
            line-height: 40px;
            margin-top: 25px;
        }

        .login-top {
            margin-top:20px;
        }

        .login-top-5 {
            margin-top: 28px;
        }

        .right {
            text-align:right;
            height:30px;
            line-height:30px;
        }

        .login-btn {
            width: 120px;
        }
    </style>
</head>
<body>
    <div class="body-content">
        <div class="login-contanier">
            <div class="row login-top">
                <div class="col-sm-12 col-md-12 col-xs-12  title-name">诊间支付后台系统登录</div>
            </div>
            <div class="row login-top-5">
                <div class="col-md-4 col-sm-4 col-xs-4 right">账户:</div>
                <div class="col-md-8  col-sm-8 col-xs-8">  <input type="text" class="form-control" id="username" placeholder="请输入账户" value="admin"></div>
            </div>
            <div class="row login-top">
                <div class="col-md-4 col-sm-4 col-xs-4  right">密码:</div>
                <div class="col-md-8 col-sm-8 col-xs-8 ">  <input type="password" class="form-control" id="password" placeholder="请输入密码" value="123qwe,./"></div>
            </div>
            <div class="row login-top ">
                <div class="col-md-offset-5 col-sm-offset-5 col-xs-offset-5">
                    @*data-toggle="modal" data-target="#myModal"*@
                    <button id="login" type="button"  data-loading-text="登录中..."class="btn btn-primary btn-lg login-btn" >登录</button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade " backdrop="static"  id="myModal" tabindex="-1" role="dialog">
        <div class="modal-dialog  modal-sm" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">消息提示</h4>
                </div>
                <div class="modal-body">
                    <p id="message">&hellip;</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>

</body>
</html>

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
<script src="/Scripts/requestAjax.js"></script>
<script type="text/javascript">
    $('#login').on('click', function () {
        var $btn = $('#login').button('loading');
        var inputData = {
            UserName: $("#username").val(),
            UserPassword: $("#password").val(),
        }

        //判断用户名名不能为空
        if (!inputData.UserName || inputData.UserName.length < 1) {

            $btn.button('reset');
            return alterMsg('登录用户名不能为空');
        }

        //if (!inputData.UserPassword || inputData.UserPassword.length < 1) {

        //    return alert('用户密码不能为空');
        //}

        request({
            url: "/Login/DoLogin",
            type: "POST",
            data: inputData,
            success: function (data) {
                $btn.button('reset');
                console.log(data);
                if (data) {
                    if (data.code == 400) {
                        return alterMsg('登录失败,' + data.msg);
                    }
                    else if (data.code == 200) {
                        window.location.href = '/Home/Index'
                    } else {
                        return alterMsg('登录失败,错误未知，ERROR-CS1009');
                    }
                } else {
                    return alterMsg('登录失败,网络错误，请稍后再试，ERROR-CS1010');
                }

            }
        })

       
       
    })

    function alterMsg(msg) {
        $("#message").text(msg);
        $("#myModal").modal({ backdrop: 'static', keyboard: false });
    }


</script>

